/* The Triangle
 * http://poj.grids.cn/practice/1163
 * Dynamic Programming
 * Jiaqing Dong
 * 2012/11/25
 */
#include<iostream>
using namespace std;

int num;
int result[101] = { 0 };
int main()
{
	int N, num0, num1, res;
	cin >> N;
	num0 = 0; num1 = 0; res = 0;
	for(int i = 0; i < N; i++) {
		for(int j = 1; j <= i+1; j++) {
			cin >> num;
			num0 = num1;
			num1 = result[j];
			result[j] = (num0 > num1 ? num0 : num1) + num;
			res = res > result[j] ? res : result[j];
		}
	}
	cout << res;
	return 0;
}